<template>
  <div class="home">
    <el-container>
      <el-header>
        <el-row :gutter="20">
          <el-col :span="4"
            ><img src="../assets/cap.png" alt="" class="logo"
          /></el-col>
          <el-col :span="16"
            ><h2 style="font-size: 26px">凯捷项目管理系统</h2></el-col
          >
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            active-text-color="#1B7FD3"
            background-color="black"
            class="el-menu-vertical-demo"
            :default-active="active"
            text-color="#fff"
            router
          >
            <!-- router开启路由模式，通过 el-menu-item index来进行跳转-->
            <el-menu-item
              :index="item.path"
              v-for="item in list"
              :key="item.path"
            >
              <span>{{ item.meta.title }}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <!-- 设置路由出口 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import { useRouter, useRoute } from "vue-router";

export default defineComponent({
  setup() {
    const router = useRouter();
    const route = useRoute();
    // console.log(router.getRoutes());//拿到页面中的所有路由
    const list = router.getRoutes().filter((v) => v.meta.isShow);
    return { list, active: route.path };
  },
});
</script>

<style lang="scss" scoped>
html,
body {
  margin: 0;
  padding: 0;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  * {
    margin: 0;
    padding: 0;
  }
  width: 200px;
  min-height: 515px;
}
.el-header {
  height: 80px;
  background-color: #000000;
  .logo {
    width: 120px;
    height: 60px;
    margin-top: 20px;
  }
  h2,
  .quit-login {
    text-align: center;
    height: 80px;
    line-height: 80px;
    color: aliceblue;
  }
}
.el-aside {
  /*  .el-menu{
    height: calc(100vh - 80px);
  } */
  .el-menu {
    height: calc(100vh - 80px);
  }
}
</style>
